package cn.java.basic;

class Book
{
    //定义数据成员
    public String strISBN;  //书号
    public String strTitle; //书名
    public String strAuthor;//作者
    public String strPublisher; //出版社
    public double dbPrice;  //定价

    //构造方法
    public Book(String isbn,String title,String author,String publisher,double price)
    {
        strISBN=isbn;
        strTitle=title;
        strAuthor=author;
        strPublisher=publisher;
        dbPrice=price;
    }

    //成员方法
    public String getPrice()
    {
        String strPrice=String.valueOf(dbPrice);
        System.out.println(strPrice);
        return strPrice;
    }

    //重写回收方法
    protected void finalize()
    {
        System.out.println("Book实例对象'"+this.strTitle+"'存储单元被回收");
    }
}

public class CreateClass
{
    public static void main(String[] args)
    {
        //BOOK对象实例化
        Book book=new Book("9787560331539","500个俄罗斯数学经典老题",
                            "刘培杰","哈尔滨工业大学出版社",
                            28);
        new Book("9787115281609","锋利的JQuery",
                "单东林","人民邮电出版社",
                49);
        new Book("9787544763981","傅雷家书",
                "傅雷","译林出版社",
                35);
        System.gc();    //申请回收垃圾
        System.out.println("程序结束");

    }
}


